<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>npm package version semver calculator | 飞翔的竹子</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="npm包版本号语义解析   目标 实现 实例    include everything greater than a particular version in the same major range use the carat (aka hat) symbol, ^ ^2.2.1   include everything greater than a particular version i">
<meta property="og:type" content="article">
<meta property="og:title" content="npm package version semver calculator">
<meta property="og:url" content="http://z2a.gitee.io/2023/02/15/npm-package-version/index.html">
<meta property="og:site_name" content="飞翔的竹子">
<meta property="og:description" content="npm包版本号语义解析   目标 实现 实例    include everything greater than a particular version in the same major range use the carat (aka hat) symbol, ^ ^2.2.1   include everything greater than a particular version i">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-02-15T13:50:45.000Z">
<meta property="article:modified_time" content="2023-02-19T01:14:59.783Z">
<meta property="article:author" content="flybamboo">
<meta property="article:tag" content="node">
<meta property="article:tag" content="npm">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="飞翔的竹子" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 4.2.1"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">飞翔的竹子</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">凤凰涅槃，死而后生，翱翔九天，十日而亡</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://z2a.gitee.io"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-npm-package-version" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2023/02/15/npm-package-version/" class="article-date">
  <time class="dt-published" datetime="2023-02-15T13:50:45.000Z" itemprop="datePublished">2023-02-15</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="p-name article-title" itemprop="headline name">
      npm package version semver calculator
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <h3 id="npm包版本号语义解析"><a href="#npm包版本号语义解析" class="headerlink" title="npm包版本号语义解析"></a>npm包版本号语义解析</h3><table>
<thead>
<tr>
<th>目标</th>
<th>实现</th>
<th>实例</th>
</tr>
</thead>
<tbody><tr>
<td>include everything greater than a particular version in the same major range</td>
<td>use the carat (aka hat) symbol, <code>^</code></td>
<td><code>^2.2.1</code></td>
</tr>
<tr>
<td>include everything greater than a particular version in the same minor range</td>
<td>use the tilde symbol, <code>~</code></td>
<td><code>~2.2.0</code></td>
</tr>
<tr>
<td>specify a range of stable versions</td>
<td>use &gt;, &lt;, =, &gt;= or &lt;= for comparisons, or - to specify an inclusive range</td>
<td><code>&gt;2.1</code> or <code>1.0.0 - 1.2.0</code></td>
</tr>
<tr>
<td>include prerelease versions like <code>alpha</code> and <code>beta</code></td>
<td>use the prerelease tag</td>
<td><code>1.0.0-rc.1</code></td>
</tr>
<tr>
<td>include multiple sets of versions</td>
<td>use || to combine</td>
<td>`^2 &lt;2.2</td>
</tr>
<tr>
<td>specify a range of prerelease versions</td>
<td>use comparisons like &gt; with a prerelease tag</td>
<td><code>&gt;1.0.0-alpha</code> or <code>&gt;=1.0.0-rc.0 &lt;1.0.1</code></td>
</tr>
</tbody></table>
<h3 id="版本号增加规则"><a href="#版本号增加规则" class="headerlink" title="版本号增加规则"></a>版本号增加规则</h3><table>
<thead>
<tr>
<th>Code status</th>
<th>Stage</th>
<th>Rule</th>
<th>Example version</th>
</tr>
</thead>
<tbody><tr>
<td>First release</td>
<td>New product</td>
<td>Start with 1.0.0</td>
<td>1.0.0</td>
</tr>
<tr>
<td>Backward compatible bug fixes</td>
<td>Patch release</td>
<td>Increment the third digit</td>
<td>1.0.1</td>
</tr>
<tr>
<td>Backward compatible new features</td>
<td>Minor release</td>
<td>Increment the middle digit and reset last digit to zero</td>
<td>1.1.0</td>
</tr>
<tr>
<td>Changes that break backward compatibility</td>
<td>Major release</td>
<td>Increment the first digit and reset middle and last digits to zero</td>
<td>2.0.0</td>
</tr>
</tbody></table>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://z2a.gitee.io/2023/02/15/npm-package-version/" data-id="cleao6ht60001usfy3iu0hfgq" data-title="npm package version semver calculator" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/node/" rel="tag">node</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/npm/" rel="tag">npm</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
  
    <a href="/2023/02/14/Markdown-notes/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Markdown notes</div>
    </a>
  
</nav>

  
</article>


</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Hexo/" rel="tag">Hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/" rel="tag">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/markdown/" rel="tag">markdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/node/" rel="tag">node</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/npm/" rel="tag">npm</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/blog/" style="font-size: 10px;">blog</a> <a href="/tags/markdown/" style="font-size: 10px;">markdown</a> <a href="/tags/node/" style="font-size: 10px;">node</a> <a href="/tags/npm/" style="font-size: 10px;">npm</a> <a href="/tags/python/" style="font-size: 10px;">python</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2023/02/">二月 2023</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2023/02/15/npm-package-version/">npm package version semver calculator</a>
          </li>
        
          <li>
            <a href="/2023/02/14/Markdown-notes/">Markdown notes</a>
          </li>
        
          <li>
            <a href="/2023/02/12/%E4%BD%BF%E7%94%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%B0%83%E8%AF%95-python/">使用命令行调试 python</a>
          </li>
        
          <li>
            <a href="/2023/02/12/setupHexoEnv/">使用 Hexo 和 gitee 搭建个人博客</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2023 flybamboo<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/js/jquery-3.4.1.min.js"></script>



  
<script src="/fancybox/jquery.fancybox.min.js"></script>




<script src="/js/script.js"></script>





  </div>
</body>
</html>